package com.zeildx.glife.database;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.zeildx.glife.Event;
import com.zeildx.glife.EventDao;
import com.zeildx.glife.dao.WordDao;
import com.zeildx.glife.entity.Word;

//singleton
@Database(entities = {Word.class, Event.class},version = 2,exportSchema = false)
public abstract class WordDatabase extends RoomDatabase {
    private static WordDatabase INSTANCE;
    public static synchronized WordDatabase getDatabase(Context context) {
        if (INSTANCE == null) {
            INSTANCE = Room.databaseBuilder(context.getApplicationContext(), WordDatabase.class, "word_database")
                    .fallbackToDestructiveMigration()
                    .build()
                    ;
        }
        return INSTANCE;
    }


    public abstract WordDao getWordDao();

    public abstract EventDao getEventDao();
}

